//
//  SXTMyViewController.m
//  SXT
//
//  Created by gaochar on 2017/3/15.
//  Copyright © 2017年 so. All rights reserved.
//

#import "SXTMyViewController.h"
/**
 我的页面展示功能的tableView
 */
#import "SXTMyMessageTableView.h"
/**
 我的页面tableView顶部展示登陆注册的view
 */
#import "SXTMyMessageHeadView.h"
/**
 注册页面
 */
#import "SXTLandingViewController.h"


@interface SXTMyViewController ()
/**
 * 顶部登录与注册view
 */
@property (nonatomic, strong) SXTMyMessageHeadView *headView;

/**
 展示功能的列表
 */
@property (nonatomic, strong) SXTMyMessageTableView *messageTable;

@end

@implementation SXTMyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.edgesForExtendedLayout = 0;
    self.view.backgroundColor = MainColor;
    
    [self.view addSubview:self.headView];

    [self.view addSubview:self.messageTable];
    
    [self addAutoLayout];
}

- (void)addAutoLayout {
    __weak typeof(self) weakSelf = self;
    // 对顶部登陆注册view添加约束
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(weakSelf.view);
        make.height.mas_equalTo(150);
    }];
    // 给tableView添加约束
    [_messageTable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view);
        make.height.mas_equalTo(176);
        make.top.equalTo(weakSelf.headView.mas_bottom).offset(35);
    }];
}

- (SXTMyMessageHeadView *)headView {
    if (!_headView) {
        _headView = [[SXTMyMessageHeadView alloc] init];
        __weak typeof(self) weakSelf = self;
        _headView.landingBlock = ^(){
            [weakSelf.navigationController pushViewController:[[SXTLandingViewController alloc] init] animated:YES];
        };
    }
    return _headView;
}

- (SXTMyMessageTableView *)messageTable {
    if (!_messageTable) {
        _messageTable = [[SXTMyMessageTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];

    }
    return _messageTable;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
